package leetcode;

public class Pro0109 {
    public static void main(String[] args) {
        System.out.println(isFlipedString("waterbottle", "erbottlewat"));
    }

    public static boolean isFlipedString(String s1, String s2) {
        // shabi solution
//        if (s1.length() != s2.length()) {
//            return false;
//        }
//        return (s2 + s2).contains(s1);

        int len1 = s1.length();
        int len2 = s2.length();

        if (len1 != len2) {
            return false;
        }
        if (s1.equals(s2)) {
            return true;
        }
        for (int i = 0; i < len1; i++) {
            if ((s1.substring(i, len1) + s1.substring(0, i)).equals(s2)) {
                return true;
            }
        }

        return false;
    }
}
